<!-- eslint-disable no-undef -->
<script setup lang="ts">
defineProps<{
  show: boolean
  actualPayment: number
  beforeClose?: () => void
}>()
const emits = defineEmits<{
  (e: 'update:show', v: boolean): void
  (e: 'submit', v: 1 | 2 | 0): void
}>()
const payMethod = ref<0 | 1 | 2>(0)
</script>
<template>
  <van-action-sheet
    :show="show"
    @update:show="emits('update:show', $event)"
    title="选择支付方式"
    :closeable="false"
    :before-close="beforeClose"
  >
    <div class="pay-type">
      <p class="amount">￥{{ actualPayment }}.00</p>
      <van-cell-group>
        <van-cell title="微信支付" @click="payMethod = 0">
          <template #icon><cp-icon name="consult-wechat" /></template>
          <template #extra
            ><van-checkbox :checked="payMethod === 0"
          /></template>
        </van-cell>
        <van-cell title="支付宝支付" @click="payMethod = 1">
          <template #icon><cp-icon name="consult-alipay" /></template>
          <template #extra
            ><van-checkbox :checked="payMethod === 1"
          /></template>
        </van-cell>
      </van-cell-group>
      <div class="btn">
        <van-button
          type="primary"
          round
          block
          @click="emits('submit', payMethod)"
          >立即支付</van-button
        >
      </div>
    </div>
  </van-action-sheet>
</template>

<style scoped lang="scss">
.pay-type {
  .amount {
    padding: 20px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
  }
  .btn {
    padding: 15px;
  }
  .van-cell {
    align-items: center;
    .cp-icon {
      margin-right: 10px;
      font-size: 18px;
    }
    .van-checkbox :deep(.van-checkbox__icon) {
      font-size: 16px;
    }
  }
}
</style>
